﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminSite.Master" AutoEventWireup="true" CodeBehind="StockList.aspx.cs" Inherits="Agents.StockList" %>

<asp:Content ID="Header" ContentPlaceHolderID="Header" runat="server">
    <script type="text/javascript" src="../Scripts/Common.js"></script>
</asp:Content>

<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
        <h1>
            צפייה במצב נוכחי של המלאי
        </h1>           
        <hr />         

        <asp:DataGrid runat="server" ID="dgProducts" AutoGenerateColumns="False"
            AllowPaging="True" PageSize="12" PagerStyle-Mode="NumericPages" 
            DataSourceID="SqlDataSource1" BackColor="White" BorderStyle="None" 
            CellPadding="3" GridLines="Both"
            onpageindexchanged="dgProducts_PageIndexChanged" 
            OnItemDataBound="dgProducts_ItemDataBound" CssClass="dataGrid" 
            Font-Names="Verdana" BorderColor="#999999" BorderWidth="1px">
            <AlternatingItemStyle BackColor="#DCDCDC" />
            <Columns>
                    <asp:BoundColumn DataField="Id" Visible="false" />
                    <asp:BoundColumn DataField="Name" HeaderText="שם" HeaderStyle-Width="40%" ItemStyle-Width="40%" FooterStyle-Width="40%" />
                    <asp:BoundColumn DataField="ItemsInStock" HeaderText="פריטים במלאי" HeaderStyle-Width="18%" ItemStyle-Width="18%" FooterStyle-Width="18%" />
                    <asp:BoundColumn DataField="Threshold" HeaderText="סף מינימום לפריטים במלאי" HeaderStyle-Width="18%" ItemStyle-Width="18%" FooterStyle-Width="18%" />
                    <asp:BoundColumn DataField="PendingItems" HeaderText="פריטים בהזמנות מלאי ממתינות"  HeaderStyle-Width="12%" ItemStyle-Width="12%" FooterStyle-Width="12%" />
                    <asp:TemplateColumn HeaderText="קבלת התראה על חוסר" HeaderStyle-Width="6%" ItemStyle-Width="6%" FooterStyle-Width="6%" >
                    <ItemTemplate>
                        <asp:CheckBox runat="server" ID="chkNotifyBelowThreshold" Enabled="false" Checked='<%# Eval("NotifyBelowThreshold") %>' />
                    </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="קבלת התראה על מלאי מת" HeaderStyle-Width="6%" ItemStyle-Width="6%" FooterStyle-Width="6%" >
                    <ItemTemplate>
                        <asp:CheckBox runat="server" ID="chkNotifyDeadStock" Enabled="false" Checked='<%# Eval("NotifyUnordered") %>' />
                    </ItemTemplate>
                    </asp:TemplateColumn>
                </Columns>
                <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                <ItemStyle BackColor="White" ForeColor="Black" />
                <PagerStyle Mode="NumericPages" BackColor="#999999" ForeColor="Black" HorizontalAlign="Center"></PagerStyle>
                <SelectedItemStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
        </asp:DataGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AgentConnectionString %>" 
            SelectCommand="SELECT [Id], [Name], [ItemsInStock], [Threshold], [NotifyBelowThreshold], 
                            SUM(ItemsNum) AS PendingItems, [NotifyUnordered]
                            FROM [Products] LEFT JOIN [StockOrdersProducts]
                            ON (Products.Id = StockOrdersProducts.ProductId)
                            GROUP BY [Id], [Name], [ItemsInStock], [Threshold], [NotifyBelowThreshold], [NotifyUnordered]
                            ORDER BY [Name]">
        </asp:SqlDataSource>
        <br />           

        <hr />
        <asp:HyperLink ID="btnNewStockOrder" Text="בצע הזמנת מלאי חדשה..." runat="server" 
                NavigateUrl="~/Admin/NewStockOrder.aspx" CssClass="alignLeft"/>
        <br />

        <div class="alignCenter">
            <asp:Button ID="backBtn" Text="חזור" runat="server" onclick="backBtn_Click" CssClass="button"/>
        </div>
</asp:Content>
